package com.gitee.wsl.time.ext


import com.gitee.wsl.mathematics.function.scale.Continuous
import com.gitee.wsl.mathematics.function.scale.Scale
import kotlinx.datetime.LocalDateTime
import kotlinx.datetime.TimeZone
import kotlinx.datetime.toInstant
import kotlinx.datetime.toLocalDateTime
import kotlin.time.ExperimentalTime

fun ClosedRange<LocalDateTime>.ticks(count: Int) = ticks(start,endInclusive,count)

@OptIn(ExperimentalTime::class)
fun ticks(start: LocalDateTime, stop: LocalDateTime, count: Int): List<LocalDateTime>
    = Scale.Continuous.time().apply { interpolateDomain(start.toInstant(TimeZone.UTC),stop.toInstant(TimeZone.UTC)) }.ticks(count).map { it.toLocalDateTime(TimeZone.UTC) }